package org.shushan.web.demo.entity;

import lombok.Getter;
import lombok.Setter;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.shushan.framework.core.entity.IdEn;
import org.shushan.framework.core.mapstruct.EnMapstruct;
import org.shushan.web.demo.response.ElasticTestVo;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Setting;

import java.io.Serializable;

/**
 * (TUser)实体
 * @author zhigang.li
 * @email 2429967859@qq.com
 * @since 2023-09-16 22:25:41
 */
@Getter
@Setter
@Document(indexName = "sys_log")
@Setting(shards = 5, replicas = 1)
public class ElasticTest implements IdEn<Long>, EnMapstruct<ElasticTestVo>, Serializable {
    private static final long serialVersionUID = -28434004787627803L;
    @Id
    private Long id;
    @Field(value = "trace_id",type = FieldType.Text,analyzer= "ik_max_word")
    private String traceId;
    @Field(value = "log_context",type = FieldType.Text,analyzer = "ik_max_word")
    private String logContext;
    @Field(value = "log_remark",type = FieldType.Text,analyzer = "ik_max_word")
    private String logRemark;

    @Override
    public ElasticTestVo toVo() {
        return ElasticTestMapper.INSTANCE.toVo(this);
    }

    @Mapper
    interface ElasticTestMapper {
        ElasticTestMapper INSTANCE = Mappers.getMapper(ElasticTestMapper.class);

        ElasticTestVo toVo(ElasticTest tUser);
    }

}

